x = 3
print(type(x))
x = 'Hello'
print(type(x))
x = [1,2,3]
print(type(x))
print(isinstance(3,int))
print(isinstance('Hello',str))
x=3#创建整型变量
print(x**2)#引用整型变量
x += 6#修改整型变量
print(x)
x=[1,2,3]
print(x)
x[1]=5
print(x)
print(x[2])
x = (1,2,3)
print(x)
#x[1] = 5 TypeError: 'tuple' object does not support item assignment
x = 3
print(id(x))
y = x
print('----------python变量----------------')
print(id(y))
x += 6
print(x)
print(id(x))
print(id(y))
x = 3
print(id(x))
y = 3
print(id(y))
y = 5
print(id(y))
print(id(x))
print('------------查看所有python关键字--------------')
import keyword
print(keyword.kwlist)
print('-------------数字-------------')
a = 999999999999999999999999999999999999999999999999999
print(a)
print(a * a)
print(a **3)
a = 3 + 4j
b = 5 + 6j
c = a + b
print(c)
print(c.real)
print(c.imag)
print(a.conjugate)
print(a * b)
print(a / b)
print('--------------字符串------------')
a = 'abc' + '123'
print(a)
a = 3.6674
print('%7.3f'%a)
print("%d:%c"%(65,65))
print("""My name is %s,and my age is %d"""%('Dong Qiaqia',20))#字符串格式化用法
print('-------------运算符与表达式-------------')
print(3/5)#除法
print(3//5)#整除运算，类似于其他语言的除法运算，四舍五入
print(3.0 / 5)
print(3.0//5)
print(13//10)
print(13/10)
print(-13/10)
print('--对整数和浮点数计算余数--')
print(3.1%2)
print(6.3%3.1)
print(6 % 2)
print(6.0 % 2)
print(6.0 % 2.0)
print(5.7 % 4.8)
print('--*运算--')
print(3 * 2)
print(2.0 * 3)
print((3+4j)*2)
print((3+4j)*(3-4j))
print('1'*5)
print("a"*10)
print([1,2,3]*3)#列表重复
print((1,2,3)*3)
print(3*'a')
print('--python表达式--')
a = [1,2,3]
b = [4,5,6]
c = a + b
print(c)
d = list(map(str,c))
print(d)
import math
print(list(map(math.sin,c)))
print('Hello'+' '+'world')
print('welcome'*3)
print(('welcome,'*3).rstrip(',')+'!')
print('--，在python中只是普通的分隔符--')
print('a' in 'b','a')
print('a' in ('b','a'))
x = 3,5
print(x)
print(3 == 3,5)
x = 3+5,7
print(x)
print('--矩阵相乘运算符@--')
import numpy
x = numpy.ones(3)#ones()函数用于生成全1举证，参数表示矩阵大小
print(x)
m = numpy.eye(3)
print(m)
m = numpy.eye(5)*6#eye()函数用于生成单位矩阵
print(m)
m[1,0] = 12
print(m)
m[2,2] = 10
print(m)
m = numpy.eye(3)*3
print(x@m)#矩阵相乘
print('-------------常用内置函数-------------')
print(dir(__builtins__))
print('--ord和chr函数--')
print(ord('A'))
print(chr(65))
print(chr(ord('A')+1))
print(str(1))
print(str(1234))
print(str([1,2,3]))
print(str((1,2,3)))
print(str({1,2,3}))
print('--max和min函数--')
import random
a = [random.randint(1,100) for i in range(10)]
a = [random.randint(1,100) for i in [1,2,3,4,5,6,7,8,9,10]]
print(a)
print(range(10))
print(max(a),min(a),sum(a))
a = [72,26,80,65,34,86,19,74,52,40]
print(sum(a)/len(a))
print(dir(math))
print(help(math.sqrt))
print(help(math.sin))
print(dir(3+4j))
print(dir(''))
print('-------------对象的删除-------------')
x = [1,2,3,4,5,6]
y = 3
z = y
print(y)
del y
#print(y)
print(z)
#del z
del x[1]
print(x)
#del x
print(x)
x = (1,2,3)
#del x[1]#TypeError: 'tuple' object doesn't support item deletion
del x
#print(x)
#x = input('Please input:')
#print(type(x))
print('--输出重定向--')
fp = open(r'E:\redirect.txt','a+')
#print('Hello,world!',file=fp)
fp.close()
for i in range(10,20):
    print(i,end='')
print('-------------模块的导入和使用-------------')
print(math.sin(0.5))
import random
x = random.random()#获得[0,1]以内的随机小数
print(x)
n = random.randint(1,100)#获得[1,100]区间上的随机整数
print(n)
import numpy as np
a = np.array((1,2,3,4))
print(a)
from math import sin
print(sin(3))
from math import sin as f
print(f(3))
print('-------------缩进-------------')
a,b,c = 3,4,5
if a>b:
    if a>c:
        print(a)
    else:
        print(c)
else:
    if b>c:
        print(b)
    else:
        print(c)
        print('ok')
print('-------------name-------------')













